﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Graphics.Effects;

namespace Yinyue200.Sharp2D.Direct2D.Effects
{
    public enum BlendEffectMode
    {
        Multiply = 0,
        Screen = 1,
        Darken = 2,
        Lighten = 3,
        Dissolve = 4,
        ColorBurn = 5,
        LinearBurn = 6,
        DarkerColor = 7,
        LighterColor = 8,
        ColorDodge = 9,
        LinearDodge = 10,
        Overlay = 11,
        SoftLight = 12,
        HardLight = 13,
        VividLight = 14,
        LinearLight = 15,
        PinLight = 16,
        HardMix = 17,
        Difference = 18,
        Exclusion = 19,
        Hue = 20,
        Saturation = 21,
        Color = 22,
        Luminosity = 23,
        Subtract = 24,
        Division = 25
    }
    public class BlendEffect : Effect
    {
        public BlendEffect()
        {
            pes.Add(null);
            Mode = BlendEffectMode.Multiply;
        }
        public override void GetEffectId(out Guid id)
        {
            id = SharpDX.Direct2D1.Effect.Blend;
        }
        public override string Name { get; set; } = nameof(BlendEffect);
        public IGraphicsEffectSource Background
        {
            get
            {
                return Source;
            }
            set
            {
                Source = value;
            }
        }
        public IGraphicsEffectSource Foreground
        {
            get
            {
                GetSource(1, out var source);
                return source;
            }
            set
            {
                pes[1] = value;
            }
        }
        public BlendEffectMode Mode
        {
            get
            {
                return (BlendEffectMode)(uint)GetProperty(nameof(Mode));
            }
            set
            {
                SetProperty(nameof(Mode), Convert(PropertyValueOwner.CreateUInt32((uint)value)),Interop.GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT);
            }
        }
    }
}
